<?php

class Third_Grid_Column {

	/**
	* Options of columns
	*/
	public $_options = array();

	/**
	 * Defines the alignment of the cell in the Body layer,
	 * not in header cell. Possible values: left, center, right
	 * @var string
	 */
	public $align;

	/**
	 * Determines the expected date format for that column
	 * @var string
	 */
	public $datefmt;

	/**
	 * Defines if the field is editable
	 * @var boolean
	 */
	public $editable;
	/**
	 * Array of allowed options (attributes) for edittype option
	 * @var array
	 */
	public $editoptions;

	/**
	 *  Rules for edit:
	 *  { Default values
	 *  	edithidden:true(false$opt );
	 *  	required:true(false$opt );
	 *  	number:true(false$opt );
	 *  	minValue:val, maxValue:val,
	 *  	email:true(false$opt );
	 *  	date:true(false)
	 *  }
	 * @var array
	 */
	public $editrules;

	/**
	 * Defines the edit type for inline and form editing
	 * Possible values: text, textarea, select, checkbox, password
	 * @var strip
	 */
	public $edittype;

	/**
	 * Format options can be defined for particular columns,
	 * overwriting the defaults from the language file.
	 * @var array
	 * @see formatter: http://www.secondpersonplural.ca/jqgriddocs/_2kn0mlo1p.htm
	 */
	public $formatoptions;

	/**
	 * The predefined types or custom function name that controls the format of this field.
	 * @var string
	 */
	public $formatter;

	/**
	 * If set to true this column will not appear in the modal dialog
	 * where users can choose which columns to show or hide.
	 * @var boolean
	 */
	public $hidedlg;

	/**
	 * Defines if this column is hidden at initialization.
	 * @var boolean
	 */
	public $hidden;

	/**
	 * Set the index name when sorting. Passed as sidx parameter.
	 * @var string
	 */
	public $index;

	/**
	 * Defines the json mapping for the column in the incoming json string
	 * @var string
	 */
	public $jsonmap;

	/**
	 * In case if there is no id from server, this can be set as as id
	 * for the unique row id. Only one column can have this property
	 * @var boolean
	 */
	public $key;

	/**
	 * When colNames array is empty, defines the heading for this column.
	 * @var string
	 */
	public $label;

	/**
	 * Set the unique name in the grid for the column
	 * @var string
	 */
	public $name;

	/**
	 * Defines if the column can be resized
	 * @var boolean
	 */
	public $resizable;

	/**
	 * When used in formedit, disables or enables searching on that column
	 * @var booelan
	 */
	public $search;

	/**
	 * Defines is this can be sorted.
	 * @var boolean
	 */
	public $sortable;

	/**
	 * Used when datatype is clientSide. Defines the type of the column for
	 * appropriate sorting. Possible values: int, float, date, text
	 * @var string
	 */
	public $sorttype;

	/**
	 * Set the initial width of the column, in pixels
	 * @var int
	 */
	public $width;

	/**
	 * Defines the xml mapping for the column in the incomming xml file
	 * @var string
	 */
	public $xmlmap;

	function __construct( $columnsOptions = array() ) {
		$this->setOptions( $columnsOptions );
	}

	function setOptions( $options ){

		if( is_array($options) ){
			foreach($options as $key=>$opt ){

				switch( $key ){
					case 'align':
						$this->setAlign( $opt );
					break;
					case 'datefmt':
						$this->setDatefmt( $opt );
					break;
					case 'editable':
						$this->setEditable( $opt );
					break;
					case 'editoptions':
						$this->setEditoptions( $opt );
					break;
					case 'editrules':
						$this->setEditrules( $opt );
					break;
					case 'edittype':
						$this->setEdittype( $opt );
					break;
					case 'formatoptions':
						$this->setFormatoptions( $opt );
					break;
					case 'formatter':
						$this->setFormatter( $opt );
					break;
					case 'hidedlg':
						$this->setHidedlg( $opt );
					break;
					case 'hidden':
						$this->setHidden( $opt );
					break;
					case 'index':
						$this->setIndex( $opt );
					break;
					case 'jsonmap':
						$this->setJsonmap( $opt );
					break;
					case 'key':
						$this->setKey( $opt );
					break;
					case 'label':
						$this->setLabel( $opt );
					break;
					case 'name':
						$this->setName( $opt );
					break;
					case 'resizable':
						$this->setResizable( $opt );
					break;
					case 'search':
						$this->setSearch( $opt );
					break;
					case 'sortable':
						$this->setSortable( $opt );
					break;
					case 'sorttype':
						$this->setSorttype( $opt );
					break;
					case 'width':
						$this->setWidth( $opt );
					break;
					case 'xmlmap':
						$this->setXmlmap( $opt );
					break;
				}
			}
		}
	}

	function get(){
			$options = array(
					'align'		=> $this->getAlign(),
					'datefmt'	=> $this->getDatefmt(),
					'editable'	=> $this->getEditable(),
					'editoptions'	=> $this->getEditoptions(),
					'editrules'	=> $this->getEditrules(),
					'edittype'	=> $this->getEdittype(),
					'formatoptions'	=> $this->getFormatoptions(),
					'formatter'	=> $this->getFormatter(),
					'hidedlg'	=> $this->getHidedlg(),
					'hidden'	=> $this->getHidden(),
					'index'		=> $this->getIndex(),
					'jsonmap'	=> $this->getJsonmap(),
					'key'		=> $this->getKey(),
					'label'		=> $this->getLabel(),
					'name'		=> $this->getName(),
					'resizable'	=> $this->getResizable(),
					'search'	=> $this->getSearch(),
					'sortable'	=> $this->getSortable(),
					'sorttype'	=> $this->getSorttype(),
					'width'		=> $this->getWidth(),
					'xmlmap'	=> $this->getXmlmap()
			);

			return $options;
	}

	function getOptions(){
		return $this->_options;
	}

	/**
	 * @param $xmlmap the $xmlmap to set
	 */
	public function setXmlmap($xmlmap) {
		$this->xmlmap = $xmlmap;
	}

	/**
	 * @param $width the $width to set
	 */
	public function setWidth($width) {
		$this->width = $width;
	}

	/**
	 * @param $sorttype the $sorttype to set
	 */
	public function setSorttype($sorttype) {
		$this->sorttype = $sorttype;
	}

	/**
	 * @param $sortable the $sortable to set
	 */
	public function setSortable($sortable) {
		$this->sortable = $sortable;
	}

	/**
	 * @param $search the $search to set
	 */
	public function setSearch($search) {
		$this->search = $search;
	}

	/**
	 * @param $resizable the $resizable to set
	 */
	public function setResizable($resizable) {
		$this->resizable = $resizable;
	}

	/**
	 * @param $name the $name to set
	 */
	public function setName($name) {
		$this->name = $name;
	}

	/**
	 * @param $label the $label to set
	 */
	public function setLabel($label) {
		$this->label = $label;
	}

	/**
	 * @param $key the $key to set
	 */
	public function setKey($key) {
		$this->key = $key;
	}

	/**
	 * @param $jsonmap the $jsonmap to set
	 */
	public function setJsonmap($jsonmap) {
		$this->jsonmap = $jsonmap;
	}

	/**
	 * @param $index the $index to set
	 */
	public function setIndex($index) {
		$this->index = $index;
	}

	/**
	 * @param $hidden the $hidden to set
	 */
	public function setHidden($hidden) {
		$this->hidden = $hidden;
	}

	/**
	 * @param $hidedlg the $hidedlg to set
	 */
	public function setHidedlg($hidedlg) {
		$this->hidedlg = $hidedlg;
	}

	/**
	 * @param $formatter the $formatter to set
	 */
	public function setFormatter($formatter) {
		$this->formatter = $formatter;
	}

	/**
	 * @param $formatoptions the $formatoptions to set
	 */
	public function setFormatoptions($formatoptions) {
		$this->formatoptions = $formatoptions;
	}

	/**
	 * @param $edittype the $edittype to set
	 */
	public function setEdittype($edittype) {
		$this->edittype = $edittype;
	}

	/**
	 * @param $editrules the $editrules to set
	 */
	public function setEditrules($editrules) {
		$this->editrules = $editrules;
	}

	/**
	 * @param $editoptions the $editoptions to set
	 */
	public function setEditoptions($editoptions) {
		$this->editoptions = $editoptions;
	}

	/**
	 * @param $editable the $editable to set
	 */
	public function setEditable($editable) {
		$this->editable = $editable;
	}

	/**
	 * @param $datefmt the $datefmt to set
	 */
	public function setDatefmt($datefmt) {
		$this->datefmt = $datefmt;
	}

	/**
	 * @param $align the $align to set
	 */
	public function setAlign($align) {
		$this->align = $align;
	}

	/**
	 * @return the $xmlmap
	 */
	public function getXmlmap() {
		return $this->xmlmap;
	}

	/**
	 * @return the $width
	 */
	public function getWidth() {
		return $this->width;
	}

	/**
	 * @return the $sorttype
	 */
	public function getSorttype() {
		return $this->sorttype;
	}

	/**
	 * @return the $sortable
	 */
	public function getSortable() {
		return $this->sortable;
	}

	/**
	 * @return the $search
	 */
	public function getSearch() {
		return $this->search;
	}

	/**
	 * @return the $resizable
	 */
	public function getResizable() {
		return $this->resizable;
	}

	/**
	 * @return the $name
	 */
	public function getName() {
		return $this->name;
	}

	/**
	 * @return the $label
	 */
	public function getLabel() {
		return $this->label;
	}

	/**
	 * @return the $key
	 */
	public function getKey() {
		return $this->key;
	}

	/**
	 * @return the $jsonmap
	 */
	public function getJsonmap() {
		return $this->jsonmap;
	}

	/**
	 * @return the $index
	 */
	public function getIndex() {
		return $this->index;
	}

	/**
	 * @return the $hidden
	 */
	public function getHidden() {
		return $this->hidden;
	}

	/**
	 * @return the $hidedlg
	 */
	public function getHidedlg() {
		return $this->hidedlg;
	}

	/**
	 * @return the $formatter
	 */
	public function getFormatter() {
		return $this->formatter;
	}

	/**
	 * @return the $formatoptions
	 */
	public function getFormatoptions() {
		return $this->formatoptions;
	}

	/**
	 * @return the $edittype
	 */
	public function getEdittype() {
		return $this->edittype;
	}

	/**
	 * @return the $editrules
	 */
	public function getEditrules() {
		return $this->editrules;
	}

	/**
	 * @return the $editoptions
	 */
	public function getEditoptions() {
		return $this->editoptions;
	}

	/**
	 * @return the $editable
	 */
	public function getEditable() {
		return $this->editable;
	}

	/**
	 * @return the $datefmt
	 */
	public function getDatefmt() {
		return $this->datefmt;
	}

	/**
	 * @return the $align
	 */
	public function getAlign() {
		return $this->align;
	}


}

?>